package com.tul.exercise.base.java8.stream.base;

import com.tul.cusa.common.util.ListUtil;
import com.tul.exercise.base.java8.common.Constant;
import com.tul.exercise.base.java8.util.BeanAtributeHelper;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;

import java.util.ArrayList;
import java.util.List;

/**
 * 艺术家类
 */
public class Artist extends Person{

    /**
     * 国籍
     */
    private String from;
    /**
     * 乐队成员
     */
    private List<Artist> members;

    /**
     * 是否是乐队
     */
    private Boolean isBank;

    public Artist() {
        super();
    }

    public Artist(String name, String from) {
        super(name);
        this.from = from;
    }

    public String toString() {
        return ToStringBuilder.reflectionToString(this, ToStringStyle.SHORT_PREFIX_STYLE);
    }

    public String getFrom() {
        return from;
    }

    public void setFrom(String from) {
        this.from = from;
    }

    public Boolean isFrom(String from) {
        return this.from.equals(from);
    }

    public Boolean isBank() {
        return ListUtil.isNotEmpty(members);
    }

    /**
     * 创建Artist
     * @return Artist
     */
    public static Artist createArtist() {
        Artist result = new Artist();
        result.setName(BeanAtributeHelper.getRandomItem(Constant.ARTIST_NAMES));
        result.setFrom(BeanAtributeHelper.getRandomItem(Constant.NATION_NAMES));
        return result;
    }

    /**
     * 创建Artist列表
     * @param num 个数
     * @return List<Artist>
     */
    public static List<Artist> createArtists(int num) {
        List<Artist> list = new ArrayList<>(num);
        for (int i = 0; i < num; i++) {
            list.add(createArtist());
        }
        return list;
    }


    public List<Artist> getMembers() {
        return members;
    }

    public void setMembers(List<Artist> members) {
        this.members = members;
    }
}
